const sumSine = (n, key, degree) => {
  const nN = Number(n);
  let sum = 0;
  for (let i = nN; i > 0; i -= 2) {
    sum += ((Math.sin(i * dToR(key) - i * dToR(degree)) * 4) / (i * Math.PI)) * 100;
  }

  sum += 100;
  return sum;
};

const dToR = (degree) => {
  return (degree / 180) * Math.PI;
};

const sumCircleCenterX = (n, degree) => {
  const nN = Number(n);
  let sum = 0;
  for (let i = nN; i > 0; i -= 2) {
    sum += ((Math.cos(i * dToR(degree)) * 4) / (i * Math.PI)) * 100;
  }
  sum += 100;
  return sum;
};

const sumCircleCenterY = (n, degree) => {
  const nN = Number(n);
  let sum = 0;
  for (let i = nN; i > 0; i -= 2) {
    sum += ((-Math.sin(i * dToR(degree)) * 4) / (i * Math.PI)) * 100;
  }
  sum += 100;
  return sum;
};

export default {};
export { sumSine, sumCircleCenterX, sumCircleCenterY };
